<!DOCTYPE html>
{extend name="common/application" /}
{block name="title"}<title>个人中心-订单详情</title>{/block}
{block name="css"}
<link rel="stylesheet" type="text/css" href="_CSS_/help.css"/>
<link rel="stylesheet" type="text/css" href="_CSS_/order.css"/>
<link rel="stylesheet" type="text/css" href="_CSS_/order_detail.css"/>
<style type="text/css">
    .productInfo a {
        margin-bottom: 15px;
    }

    .productInfo span {
        margin-top: 5px;
    }

    .operations {
        margin-left: 573px;
    }

    .productType {
        margin-left: 78px;
    }

    .productPrices {
        margin-left: 214px;
        width: 170px;
    }

    .operation {
        margin-left: 210px;
    }
	.flows01{background:url(/static/web/images/flow03.png) no-repeat !important;}
</style>
{/block}


<!-- 主体内容 -->
{block name="content"}

<!-- 主体内容 -->
<div class="main">
    <div class="details">
        <!--面包屑导航-->
        <div class="breadcrumb">
            <p>当前位置：
                <a href="{:url('index/person/order')}">订单管理</a> &gt;
                <a class="curPage" href="javascript:;">我的订单</a>
            </p>
        </div>
        <!--订单流程-->
        <div class="flows">
            <div class="steps current">
                <span>报价</span>
                <span class="icons icon-success01"></span>
                <span class="icons icon-grey"></span>
                <p class="times"></p>
            </div>
            <div class="steps">
                <span>授权</span>
                <span class="icons icon-success01"></span>
                <span class="icons icon-grey"></span>
                <p class="times"></p>
            </div>
            <div class="steps">
                <span>付款</span>
                <span class="icons icon-success01"></span>
                <span class="icons icon-grey"></span>
                <p class="times"></p>
            </div>
            <div class="steps">
                <span>下载</span>
                <span class="icons icon-success01"></span>
                <span class="icons icon-grey"></span>
                <p class="times"></p>
            </div>
            <div class="steps">
                <span>确认</span>
                <span class="icons icon-success01"></span>
                <span class="icons icon-grey"></span>
                <p class="times"></p>
            </div>
            <div class="steps mr0">
                <span>完成</span>
                <span class="icons icon-success01"></span>
                <span class="icons icon-grey"></span>
                <p class="times"></p>
            </div>
        </div>
        <div class="flows flows01" style="display: none">
            <div class="steps current step">
                <span>待付款</span>
                <span class="icons icon-success01"></span>
                <span class="icons icon-grey"></span>
                <p class="time"></p>
            </div>
            <div class="steps step">
                <span>待下载</span>
                <span class="icons icon-success01"></span>
                <span class="icons icon-grey"></span>
                <p class="time"></p>
            </div>
            <div class="steps step">
                <span>待确认</span>
                <span class="icons icon-success01"></span>
                <span class="icons icon-grey"></span>
                <p class="time"></p>
            </div>
            <div class="steps step">
                <span>待接收</span>
                <span class="icons icon-success01"></span>
                <span class="icons icon-grey"></span>
                <p class="time"></p>
            </div>
            <div class="steps step">
                <span>已完成</span>
                <span class="icons icon-success01"></span>
                <span class="icons icon-grey"></span>
                <p class="time"></p>
            </div>
        </div>
        <!--订单信息-->
        <div class="ordersInfo">
            <div class="leftCon fl">
                <h5>订单信息</h5>
                <p><label>宝贝类型：</label><span class="type"></span></p>
                <p><label>订单编号：</label><span class="number name"></span></p>
                <p><label>店铺名称：</label><span class="store name"></span></p>
                <p><label>成交时间：</label><span class="time name"></span></p>
            </div>
            <div class="rightCon fl">
                <p class="strong">当前状态：<span class="status"></span></p>
                <p class="caking"></p>
            </div>
        </div>
        <!--订单列表-->
        <div class="orderList">
            <div class="listItem">
                <div class="listItemHeader">
                    <p class="time name"></p>
                    <p class="orderNo">订单编号：<span class="name"></span></p>
                    <p class="operations">操作</p>
                </div>
                <div class="listItemBody">
                    <a class="imgBox" href="javascript:;">
                        <img class="name" src="">
                    </a>
                    <div class="productInfo">
                        <a class="title moreline name" limit="15" href="javascript:;"></a>
                        <span class="category"></span>
                        <span class="category"></span>
                    </div>
                    <p class="productType"></p>
                    <p class="productPrices prices"></p>
                    <div class="operation">
                        <p class="leftTime status"></p>
                    </div>
                </div>
                <!--<div class="listItemFooter hide">-->
                <!--<a class="refund" href="javascript:;"><span class="icons icon-refund"></span>退款</a>-->
                <!--<a class="appeal" href="javascript:;"><span class="icons icon-appeal"></span>申诉</a>-->
                <!--</div>-->
            </div>
        </div>
    </div>
</div>
<!-- 底部信息 -->
{/block}


{block name="js"}
<script src="_JS_/jquery-1.8.3.min.js"></script>
<script src="_P_/layer/layer.js"></script>
<script src="_JS_/jquery.base64.js"></script>
<script src="_JS_/jquery.cookie.js"></script>
<script src="_JS_/common.js"></script>
<script src="_JS_/order.js"></script>
<script src="_JS_/getDate.js"></script>
<script>
    $(function () {
        var url = window.location.href;
        var id = url.split("=")[1];
        var type = url.split("=")[2];

        var userinfo = $.cookie('userinfo');
        if (userinfo != null) {
			var user_login = $.base64.decode(userinfo).split(",");
            $.ajax({
                type: 'GET',
                url: "{:url('api/form/order_details')}",
                dataType: 'jsonp',
                jsonp: 'callback',
                data: {id: id, 'type': type,'uid':user_login[0]},
                success: function (msg) {
                    if (msg.code == 200) {

                        $(".name").eq(0).html(msg.data.order);
                        $(".name").eq(1).html(msg.data.name);
                        $(".name").eq(2).html(getMyDate(msg.data.time * 1000));
                        $(".name").eq(3).html(getMyDate(msg.data.time * 1000));
                        $(".name").eq(4).html(msg.data.order);
						var store = number_format(msg.data.king, 2, ".", ",");
						var king = number_format(msg.data.store, 2, ".", ",");
						
						if(type == 1){
							var money = number_format(msg.data.money, 2, ".", ",");
			
							$(".prices").html("<span style='color:#333;'>原价：</span><span style='color:red'>￥"+store+"</span><br><span style='color:#333'>报价：</span><span style='color:red;'>￥"+money+"</span>");
						}else{
							$(".prices").html("<span style='color:#333;'>价格：</span><span style='color:red'>￥"+king+"</span>");
						}
                        

                        if (msg.data.services == 1) {
                            $(".times").eq(0).html(getMyDate(msg.data.time * 1000));

							if(msg.data.static == 3){
							}else{
								if (msg.data.count1 != null) {
									$(".times").eq(1).html(getMyDate(msg.data.count1 * 1000));
									$(".steps").eq(1).addClass('current');
								}
								if (msg.data.count2 != null) {
									$(".times").eq(2).html(getMyDate(msg.data.count2 * 1000));
									$(".steps").eq(2).addClass('current');
								}
								if (msg.data.count3 != null) {
									$(".times").eq(3).html(getMyDate(msg.data.count3 * 1000));
									$(".steps").eq(3).addClass('current');
								}
								if (msg.data.count4 != null) {
									$(".times").eq(4).html(getMyDate(msg.data.count4 * 1000));
									$(".steps").eq(4).addClass('current');
								}
								if (msg.data.count5 != null) {
									$(".times").eq(5).html(getMyDate(msg.data.count5 * 1000));
									$(".steps").eq(5).addClass('current');
								}
							}

                            $(".name").eq(5).attr('src', '/Images/tradingMarket/' + msg.data.image);
                            $(".name").eq(6).html(msg.data.username);
                            $(".category").eq(0).html('交易方式：<span class="name"></span>');
                            $(".category").eq(1).html('行业分类：<span class="name"></span>');
                            $(".name").eq(7).html(msg.data.trading_name);
                            $(".name").eq(8).html(msg.data.market_name);

                            $(".type").text('交易类宝贝');
                            $(".productType").text('交易类商品');
                            if (msg.data.statuc == 1) {
                                $(".status").html('买家已提交订单，等待选择买家');
                                $(".caking").html("超过<span class=\"leftTime\">3</span>天未选择，订单将自动关闭")
                            } else if (msg.data.statuc == 2 && msg.data.static != 3) {
                                $(".status").html('已选择买家，等待买家付款');
                                $(".caking").html("超过<span class=\"leftTime\">14</span>天未付款，订单将自动关闭")
                            } else if (msg.data.statuc == 3 && msg.data.static != 3) {
                                $(".status").html('已付款，等待上传专利文件');
                            } else if (msg.data.statuc == 4 && msg.data.static != 3) {
                                $(".status").html('商家专利文件已上传，等待下载');
                            } else if (msg.data.statuc == 5 && msg.data.static != 3) {
                                $(".status").html('文件下载成功,待确认文件');
                            } else if (msg.data.statuc == 6 && msg.data.static != 3) {
                                $(".status").html('待卖家上传快递单号');
                            } else if (msg.data.statuc == 7 && msg.data.static != 3) {
                                $(".status").html('卖家已邮件文件');
                            } else if (msg.data.statuc == 9 && msg.data.static != 3) {
                                $(".status").html('文件已确认接收,订单结束');
                            } else if (msg.data.statuc == 10 && msg.data.static != 3) {
                                $(".status").html('买家14个自然日内没有付款，订单取消');
                            } else if (msg.data.statuc == 11 && msg.data.static != 3) {
                                $(".status").html('长时间未操作,订单取消');
                            } else if (msg.data.statuc == 12 && msg.data.static != 3) {
                                $(".status").html('买家取消订单');
                            }else if(msg.data.statuc == 14 && msg.data.static != 3){
								$(".status").html('退款成功，订单结束');
							}else if(msg.data.static == 3){
								$(".status").html('商家选择其他买家');
							}
                        } else {
                            $(".time").eq(0).html(getMyDate(msg.data.time * 1000));

                            if (msg.data.count1 != null) {
                                $(".time").eq(1).html(getMyDate(msg.data.count1 * 1000));
                                $(".step").eq(1).addClass('current');
                            }
                            if (msg.data.count2 != null) {
                                $(".time").eq(2).html(getMyDate(msg.data.count2 * 1000));
                                $(".step").eq(2).addClass('current');
                            }
                            if (msg.data.count3 != null) {
                                $(".time").eq(3).html(getMyDate(msg.data.count3 * 1000));
                                $(".step").eq(3).addClass('current');
                            }
                            if (msg.data.count4 != null) {
                                $(".time").eq(4).html(getMyDate(msg.data.count4 * 1000));
                                $(".step").eq(4).addClass('current');
                            }


                            $(".flows").eq(1).attr('style', 'display:block');
                            $(".flows").eq(0).attr('style', 'display:none');
                            $(".category").eq(1).html('服务分类：<span class="name"></span>');
                            $(".type").text('服务类宝贝');
                            $(".productType").text('服务类商品');
                            $(".status").html(msg.data.list_name);
							if(msg.data.statuc==1){
							$(".caking").html(dateDiff(msg.data.time));
							}
                            
                            $(".name").eq(5).attr('src', '/Images/serviceGoods/' + msg.data.image);
                            $(".name").eq(6).html(msg.data.username);
                            $(".name").eq(7).html(msg.data.trading_name);
                        }
                    } else {
                        layer.msg('查询失败!', {icon: 1, time: 1000});
                    }
                }
            })
        } else {
            window.location.href = "{:url('index/login/index')}";
        }
    })

    /**格式化剩余时间**/
    var dateDiff = function (timestamp) {
        // 补全为13位
        var arrTimestamp = (timestamp + '').split('');
        for (var start = 0; start < 13; start++) {
            if (!arrTimestamp[start]) {
                arrTimestamp[start] = '0';
            }
        }
        timestamp = arrTimestamp.join('') * 1;

        var minute = 1000 * 60;
        var hour = minute * 60;
        var day = hour * 24;

        var now = new Date().getTime();
        var Value = now - timestamp;
        var diffValue = day - Value;

        // 如果本地时间反而小于变量时间
        if (diffValue < 0) {
            return '订单已失效';
        }
        var dayC = diffValue / day;
        var hourC = diffValue / hour;
        var minC = diffValue / minute;

        // 数值补0方法
        var zero = function (value) {
            if (value < 10) {
                return '0' + value;
            }
            return value;
        };
        // 使用
        if (dayC >= 1) {
            // 超过1天，直接显示年月日
            /**return (function () {
                var date = new Date(timestamp);
                return "剩余" + date.getFullYear() + '年' + zero(date.getMonth() + 1) + '月' + zero(date.getDate()) + '日';
            })();**/
			return "剩余23小时";
        } else if (hourC >= 1) {
            return "剩余" + parseInt(hourC) + "小时";
        } else if (minC >= 1) {
            return "剩余" + parseInt(minC) + "分钟";
        }
    };
</script>
{/block}

